import Vuex from 'vuex'
import Vue from 'vue'
Vue.use(Vuex);
// 从localStorage中获取已有的数据，解决vuex刷新失去数据的问题
let userInfo = JSON.parse(localStorage.getItem('userInfo')) || null
const store = new Vuex.Store({
    state: {
        userInfo: userInfo 
    },
    getters: {},
    mutations: {
        saveUserInfo(state, payload) {
            state.userInfo = payload;
            localStorage.setItem('userInfo', JSON.stringify(payload))
        }
    },
    actions: {}
})

export default store